package com.nebula.core.dsl.builder;

/**
 * @author zhangtao
 */
public interface GoStatementBuilder extends StatementBuilder {

    interface GoStatement extends GoStart, GoStepOut, GoFromOut, GoOverOut,
            GoWhereOut, GoGroupOut, GoOrderOut, GoLimitOut, GoYieldOut, GoGroupYieldOut {

    }

    interface GoStart extends GoStep, GoFrom {

    }

    interface GoStep {
        /**
         * 检索步长
         *
         * @param start
         * @param end
         * @return
         */
        GoStepOut steps(int start, int end);

        /**
         * 检索步长
         *
         * @param end
         * @return
         */
        GoStepOut steps(int end);
    }

    interface GoStepOut extends GoFrom {
    }

    interface GoFrom {
        /**
         * 检索vid
         *
         * @param vids
         * @return
         */
        GoFromOut from(Object... vids);

        /**
         * 检索使用引用变量
         *
         * @param reference
         * @return
         */
        GoFromOut fromPipe(String reference);
    }

    interface GoFromOut extends GoOver, GoWhere, GoYield, GoLimit, GoGroup, Build {

    }

    interface GoOver {
        /**
         * 检索边类型
         *
         * @param in
         * @param out
         * @param edgeType
         * @return
         */
        GoOverOut over(boolean in, boolean out, String... edgeType);
    }

    interface GoOverOut extends GoWhere, GoYield, GoLimit, Build {

    }

    interface GoWhere {
        /**
         * 检索and条件
         *
         * @param key
         * @param operator
         * @param value
         * @return
         */
        GoWhereOut and(String key, String operator, Object value);

        /**
         * 检索or条件
         *
         * @param key
         * @param operator
         * @param value
         * @return
         */
        GoWhereOut or(String key, String operator, Object value);
    }

    interface GoWhereOut extends GoWhere, GoYield {
    }

    interface GoYield {
        /**
         * 返回字段
         *
         * @param field
         * @param alias
         * @return
         */
        GoYieldOut yield(String field, String alias);

        /**
         * 返回字段
         *
         * @param field
         * @return
         */
        GoYieldOut yield(String field);
    }

    interface GoYieldOut extends GoYield, GoOrder, GoLimit, GoGroup, Build {

    }

    interface GoGroup {
        /**
         * 分组
         *
         * @param fields
         * @return
         */
        GoGroupOut groupBy(String... fields);

    }

    interface GoGroupOut extends GoGroupYield, GoOrder, GoLimit, Build {

    }

    interface GoOrder {
        /**
         * 排序
         *
         * @param field
         * @param order
         * @return
         */
        GoOrderOut orderBy(String field, String order);

        /**
         * 排序
         *
         * @param field
         * @return
         */
        GoOrderOut orderBy(String field);
    }

    interface GoOrderOut extends GoLimit, Build {

    }

    interface GoLimit {
        /**
         * 分页
         *
         * @param pageNo
         * @param pageSize
         * @return
         */
        GoLimitOut limit(int pageNo, int pageSize);
    }

    interface GoLimitOut extends Build {
    }

    interface GoGroupYield {
        /**
         * 返回字段
         *
         * @param field
         * @param alias
         * @return
         */
        GoGroupYieldOut groupYield(String field, String alias);

        /**
         * 返回字段
         *
         * @param field
         * @return
         */
        GoGroupYieldOut groupYield(String field);
    }

    interface GoGroupYieldOut extends GoGroupYield, Build {

    }

}
